package com.ruoyi.dailyoperations.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.dailyoperations.mapper.WarrantyResultMapper;
import com.ruoyi.dailyoperations.domain.WarrantyResult;
import com.ruoyi.dailyoperations.service.IWarrantyResultService;

/**
 * 维修结果Service业务层处理
 *
 * @author ruoyi
 * @date 2024-09-14
 */
@Service
public class WarrantyResultServiceImpl implements IWarrantyResultService
{
    @Autowired
    private WarrantyResultMapper warrantyResultMapper;

    /**
     * 查询维修结果
     *
     * @param id 维修结果主键
     * @return 维修结果
     */
    @Override
    public WarrantyResult selectWarrantyResultById(Long id)
    {
        return warrantyResultMapper.selectWarrantyResultById(id);
    }

    /**
     * 查询维修结果列表
     *
     * @param warrantyResult 维修结果
     * @return 维修结果
     */
    @Override
    public List<WarrantyResult> selectWarrantyResultList(WarrantyResult warrantyResult)
    {
        return warrantyResultMapper.selectWarrantyResultList(warrantyResult);
    }

    /**
     * 新增维修结果
     *
     * @param warrantyResult 维修结果
     * @return 结果
     */
    @Override
    public int insertWarrantyResult(WarrantyResult warrantyResult)
    {
        if (warrantyResult.getMaintainResult() != null)
        return warrantyResultMapper.insertWarrantyResult(warrantyResult);
            // 获取当前时间
            Date currentTime = new Date();
            warrantyResult.setMaintainTime(currentTime);
        System.out.println(warrantyResult);
        return warrantyResultMapper.insertWarrantyResult(warrantyResult);
    }

    /**
     * 修改维修结果
     *
     * @param warrantyResult 维修结果
     * @return 结果
     */
    @Override
    public int updateWarrantyResult(WarrantyResult warrantyResult)
    {
        return warrantyResultMapper.updateWarrantyResult(warrantyResult);
    }

    /**
     * 批量删除维修结果
     *
     * @param ids 需要删除的维修结果主键
     * @return 结果
     */
    @Override
    public int deleteWarrantyResultByIds(Long[] ids)
    {
        return warrantyResultMapper.deleteWarrantyResultByIds(ids);
    }

    /**
     * 删除维修结果信息
     *
     * @param id 维修结果主键
     * @return 结果
     */
    @Override
    public int deleteWarrantyResultById(Long id)
    {
        return warrantyResultMapper.deleteWarrantyResultById(id);
    }
}
